home *** CD-ROM | disk | FTP | other *** search
- #
- # Copyright 2008 Adobe Systems Incorporated. All Rights Reserved.
- #
-
- # Returns 0 if version of running system is >= kMinimumRequiredVersion
- # as defined below. Returns 1 if an error is encountered, or if the
- # version of the running system is < kMinimumRequiredVersion.
-
- BEGIN {
- # Declare & Define statics
- kSuccess = 0
- kError = 1
-
- kMinimumRequiredVersion = "10.4.0"
- componentCount = split(kMinimumRequiredVersion, kMinimumRequiredVersionComponents, ".")
-
- # get data
- getline
- comparisonComponentCount = split($0, versionComponents, ".")
-
- # Must have at least 1 component in the version tuple.
- if (comparisonComponentCount < 1) {
- exit kError
- }
-
- # This script compares the first 'n' number of components in the
- # tuple, where 'n' is the number of componets in the
- # minimumRequired comparison tuple. It pads out the returned value
- # with zeroes as necessary.
- if (comparisonComponentCount < componentCount)
- {
- for(i = comparisonComponentCount + 1; i <= componentCount; i++)
- {
- versionComponents[i] = 0
- }
- }
-
- # Compare version components piece-by-piece from left to right.
- # Conditions: For each component:
- # if systemValue > minimumRequired value, exit successfully.
- # if systemValue < minimumRequired value, exit with failure.
- # if systemValue == minimumRequired value, continue to test
- # next component, unless we've tested all of the
- # returned system component values (up to and
- # including the last digit), in which case, exit successfully.
-
- # Note: split()-created arrays are 1-based in awk.
- for (i = 1; i <= componentCount; i++)
- {
- currentComponentDigit = int(versionComponents[i])
- if (currentComponentDigit > kMinimumRequiredVersionComponents[i]) {
- exit kSuccess
- }
- if (currentComponentDigit < kMinimumRequiredVersionComponents[i]) {
- exit kError
- }
- if (currentComponentDigit == kMinimumRequiredVersionComponents[i]) {
- if (i == componentCount) {
- exit kSuccess
- }
- }
- }
-
- # Execution should never get here based on the logic in the for-loop above.
- exit kError
- }
-